package com.zzjson.thread.join;

/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2019 shuncom team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : com.zzjson.thread.join</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2019年08月21日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
public class JoinRule {


	static int x = 0;

	public static void main(String[] args) throws InterruptedException {
        /*Thread t1=new Thread(()->{
            x=100;
        });
        t1.start();
        t1.join();
        System.out.println(x);*/

		Thread t1 = new Thread(() -> {
			System.out.println("t1");
			//执行的结果对于主线程可见
		});
		Thread t2 = new Thread(() -> {
			System.out.println("t2");
		});
		Thread t3 = new Thread(() -> {
			System.out.println("t3");
		});
		t1.start();
		t1.join(); //阻塞主线程 wait/notify
		//等到阻塞释放
		//获取到t1线程的执行结果.
		t2.start();
		t2.join(); // 建立一个happens-bebefore规则

		t3.start();
	}
}